﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.IO;

namespace WpfIPodControlsTest
{
    /// <summary>
    /// Interaction logic for PhotoDemo.xaml
    /// </summary>
    public partial class PhotoDemo : UserControl
    {
        public PhotoDemo()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            pageScroller.CurrentIndex = pageScroller.CurrentIndex - 1;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            pageScroller.CurrentIndex = pageScroller.CurrentIndex + 1;
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            //pageScroller.ItemsSource = GetImages(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures");
            System.Windows.Forms.FolderBrowserDialog opf = new System.Windows.Forms.FolderBrowserDialog();
            if (opf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pageScroller.ItemsSource = GetImages(opf.SelectedPath);
            }            
        }

        private System.Collections.IEnumerable GetImages(string path)
        {
            var query = from file in Directory.GetFiles(path, "*.jpg")
                        select file;
            return query;
        }
    }
}
